﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterpagecuatui.Master" AutoEventWireup="true" CodeBehind="Multiple-choice.aspx.cs" Inherits="tracnghiemonline2.Default" %>

<%@ Import Namespace="DataAccess" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Trắc Nghiệm - Tiếng nhật thật dễ</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="page-main-content w3-row w3-padding w3-light-grey">
        <div class="w3-twothird w3-padding">
            <%var get_cer = new TblCertificateController().FetchAll().Where(x => x.CerActive == true).ToList();
              var get_cer_res = new TblCertificateController().FetchAll().Where(x => x.CerActive == true);
              var get_rank_total = (from p in new TblRankTotalController().FetchAll() orderby p.ScoreTotal descending select p).ToList();
            %>
            <ul class="w3-navbar w3-hide-small">
                <%if (get_cer.Count != 0)
                  {%>
                <li><a href="javascript:;" class="cer-link w3-topbar w3-white w3-border-teal" onclick="chontrinhdo(event, 'trinhdo<%=get_cer[0].CerId %>')"><%=get_cer[0].CerTitle %></a></li>

                <%for (int i = 1; i < get_cer.Count; i++)
                  { %>
                <li><a href="javascript:;" class="cer-link w3-topbar w3-grey w3-border-grey" onclick="chontrinhdo(event, 'trinhdo<%=get_cer[i].CerId %>')"><%=get_cer[i].CerTitle %></a></li>
                <%} %>
                <%} %>
            </ul>
            <select id="sl_cer_res" class="select-cer-res w3-hide-large w3-hide-medium w3-margin-bottom">
                <%foreach (TblCertificate cer_res in get_cer_res)
                  { %>
                <option value="<%=cer_res.CerId %>"><%=cer_res.CerTitle %> </option>
                <%} %>
            </select>
            <%if (get_cer.Count != 0)
              {%>
            <div id="trinhdo<%=get_cer[0].CerId %>" class="cer-content w3-white w3-row w3-padding">
                <%var get_test = from p in new TblTestController().FetchAll().Where(x => x.TestActive == true && x.TestCertificate == get_cer[0].CerId) orderby p.TestTitle ascending select p;
                  foreach (TblTest test in get_test)
                  {
                      if (checkLevel(test.TestLevel))
                      {
                %>
                <a href="<%=convertToUrl(convertToUnSign(test.TestTitle))%>-<%=test.TestId%>">
                    <div class="cer-test-item hvr-float-shadow w3-quarter" data-toggle="tooltip" data-placement="bottom" title="<%=test.TestTitle%>">
                        <div class="cer-test-picture w3-row w3-display-container">
                            <img src="../Content/img/logo_sqt.jpg" />
                            <%if (Session["level"] != null)
                              {%>
                            <div class="cer-test-unlock w3-display-bottommiddle"><span class="w3-xxlarge w3-text-white"><%=getMaxScore(test.TestId) %>/100</span></div>
                            <%} %>
                        </div>
                        <div class="cer-test-tittle w3-center w3-teal">
                            <span><%=test.TestTitle%></span>
                        </div>
                    </div>
                </a>

                <%}
                      else
                      { %>
                <div class="cer-test-item hvr-float-shadow w3-quarter" data-toggle="tooltip" data-placement="bottom" title="<%=test.TestTitle%>">
                    <div class="cer-test-picture w3-row w3-display-container">
                        <img src="../Content/img/logo_sqt.jpg" />
                        <div class="cer-test-lock w3-display-bottommiddle"><i class="w3-xxlarge w3-text-white fa fa-lock"></i></div>
                    </div>
                    <div class="cer-test-tittle w3-center w3-teal">
                        <span><%=test.TestTitle%></span>
                    </div>
                </div>
                <%}
                  } %>
            </div>
            <%for (int i = 1; i < get_cer.Count; i++)
              { %>
            <div id="trinhdo<%=get_cer[i].CerId %>" class="cer-content w3-white w3-row w3-padding" style="display: none">
                <%var get_test2 = from p in new TblTestController().FetchAll().Where(x => x.TestActive == true && x.TestCertificate == get_cer[i].CerId) orderby p.TestTitle ascending select p;
                  foreach (TblTest test in get_test2)
                  {
                      if (checkLevel(test.TestLevel))
                      {
                %>
                <a href="<%=convertToUrl(convertToUnSign(test.TestTitle))%>-<%=test.TestId%>">
                    <div class="cer-test-item hvr-float-shadow w3-quarter" data-toggle="tooltip" data-placement="bottom" title="<%=test.TestTitle%>">
                        <div class="cer-test-picture w3-row w3-display-container">
                            <img src="../Content/img/logo_sqt.jpg" />
                            <div class="cer-test-unlock w3-display-bottommiddle"><span class="w3-xxlarge w3-text-white">100/100</span></div>
                        </div>
                        <div class="cer-test-tittle w3-center w3-teal">
                            <span><%=test.TestTitle%></span>
                        </div>
                    </div>
                </a>

                <%}
                      else
                      { %>
                <div class="cer-test-item hvr-float-shadow w3-quarter" data-toggle="tooltip" data-placement="bottom" title="<%=test.TestTitle%>">
                    <div class="cer-test-picture w3-row w3-display-container">
                        <img src="../Content/img/logo_sqt.jpg" />
                        <div class="cer-test-lock w3-display-bottommiddle"><i class="w3-xxlarge w3-text-white fa fa-lock"></i></div>
                    </div>
                    <div class="cer-test-tittle w3-center w3-teal">
                        <span><%=test.TestTitle%></span>
                    </div>
                </div>
                <%}
                  } %>
            </div>
            <%} %>
            <%} %>
        </div>
        <div class="w3-third w3-padding">
            <header class="w3-padding w3-center w3-teal w3-large">BẢNG XẾP HẠNG</header>
            <ul class="w3-navbar w3-row w3-center">
                <li class="w3-half"><a href="javascript:;" class="top-link w3-white w3-border-teal" onclick="chonxephang(event, 'xephang1')">THÁNG <%=this.date %></a></li>
                <li class="w3-half"><a href="javascript:;" class="top-link w3-grey w3-border-grey" onclick="chonxephang(event, 'xephang2')">TẤT CẢ</a></li>
            </ul>
            <div id="xephang1" class="top-content w3-white">
                <ul class="top-user-list w3-ul">
                    <%
                        int count_month = this.month_id.Count;
                        if (count_month == 0)
                        { %>
                    <li class="w3-row">
                        <label>Chưa có thông số bảng xếp hạng. Làm bài ngay!</label>
                    </li>
                    <%}
                        else
                        {
                            var get_top1 = new TblUserController().FetchAll().Where(x => x.UserId == month_id[0]).Single();
                    %>
                    <li class="w3-row">
                        <div class="top-type w3-col l2">
                            <img src="../Content/img/gold-medal.png" />
                        </div>
                        <div class="w3-col l2">
                            <img src="../Content/avatar/<%=get_top1.Avatar%>" />
                        </div>
                        <div class="w3-col l7">
                            <label><%=get_top1.FullName%></label><br />
                            <label class="w3-text-teal"><%=this.month_score[0]%></label><span> Điểm</span>
                        </div>
                    </li>
                    <%if (count_month > 1)
                      {
                          var get_top2 = new TblUserController().FetchAll().Where(x => x.UserId == month_id[1]).Single();
                    %>
                    <li class="w3-row">
                        <div class="top-type w3-col l2">
                            <img src="../Content/img/silver-medal.png" />
                        </div>
                        <div class="w3-col l2">
                            <img src="../Content/avatar/<%=get_top2.Avatar %>" />
                        </div>
                        <div class="w3-col l7">
                            <label><%=get_top2.FullName %></label><br />
                            <label class="w3-text-teal"><%=this.month_score[1] %></label><span> Điểm</span>
                        </div>
                    </li>
                    <%if (count_month > 2)
                      {
                          var get_top3 = new TblUserController().FetchAll().Where(x => x.UserId == month_id[2]).Single();
                    %>
                    <li class="w3-row">
                        <div class="top-type w3-col l2">
                            <img src="../Content/img/bronze-medal.png" />
                        </div>
                        <div class="w3-col l2">
                            <img src="../Content/avatar/<%=get_top3.Avatar%>" />
                        </div>
                        <div class="w3-col l7">
                            <label><%=get_top3.FullName%></label><br />
                            <label class="w3-text-teal"><%=this.month_score[2]%></label><span> Điểm</span>
                        </div>
                    </li>
                    <%
                          if (count_month > 3)
                          {
                              if (count_month > 10)
                                  count_month = 10;
                              for (int i = 3; i < count_month; i++)
                              {
                                  if (this.month_id[i] == 0)
                                      break;
                                  var get_top10 = new TblUserController().FetchAll().Where(x => x.UserId == month_id[i]).Single();
                    %>
                    <li class="w3-row">
                        <div class="top-type w3-col l2 w3-padding">
                            <label class="w3-large"><%=i + 1 %></label>
                        </div>
                        <div class="w3-col l2">
                            <img src="../Content/avatar/<%=get_top10.Avatar %>" />
                        </div>
                        <div class="w3-col l7">
                            <label><%=get_top10.FullName %></label><br />
                            <label class="w3-text-teal"><%=this.month_score[i] %></label><span> Điểm</span>
                        </div>
                    </li>
                    <%}
                          }
                      }
                      }
                      }%>
                </ul>
            </div>
            <div id="xephang2" class="top-content w3-row w3-white" style="display: none">
                <ul class="top-user-list w3-ul">
                    <%
                        int count_total = total_id.Count;
                        if (count_total == 0)
                        { %>
                    <li class="w3-row">
                        <label>Chưa có thông số bảng xếp hạng. Làm bài ngay!</label>
                    </li>
                    <%}
                        else
                        {
                            var get_top1 = new TblUserController().FetchAll().Where(x => x.UserId == total_id[0]).Single();
                    %>
                    <li class="w3-row">
                        <div class="top-type w3-col l2">
                            <img src="../Content/img/gold-medal.png" />
                        </div>
                        <div class="w3-col l2">
                            <img src="../Content/avatar/<%=get_top1.Avatar%>" />
                        </div>
                        <div class="w3-col l7">
                            <label><%=get_top1.FullName%></label><br />
                            <label class="w3-text-teal"><%=this.total_score[0]%></label><span> Điểm</span>
                        </div>
                    </li>
                    <%if (count_total > 1)
                      {
                          var get_top2 = new TblUserController().FetchAll().Where(x => x.UserId == total_id[1]).Single();
                    %>
                    <li class="w3-row">
                        <div class="top-type w3-col l2">
                            <img src="../Content/img/silver-medal.png" />
                        </div>
                        <div class="w3-col l2">
                            <img src="../Content/avatar/<%=get_top2.Avatar %>" />
                        </div>
                        <div class="w3-col l7">
                            <label><%=get_top2.FullName %></label><br />
                            <label class="w3-text-teal"><%=this.total_score[1] %></label><span> Điểm</span>
                        </div>
                    </li>
                    <%if (count_total > 2)
                      {
                          var get_top3 = new TblUserController().FetchAll().Where(x => x.UserId == total_id[2]).Single();
                    %>
                    <li class="w3-row">
                        <div class="top-type w3-col l2">
                            <img src="../Content/img/bronze-medal.png" />
                        </div>
                        <div class="w3-col l2">
                            <img src="../Content/avatar/<%=get_top3.Avatar%>" />
                        </div>
                        <div class="w3-col l7">
                            <label><%=get_top3.FullName%></label><br />
                            <label class="w3-text-teal"><%=this.total_score[2]%></label><span> Điểm</span>
                        </div>
                    </li>
                    <%
                          if (count_total > 3)
                          {
                              if (count_total > 10)
                                  count_total = 10;
                              for (int i = 3; i < count_total; i++)
                              {
                                  var get_top10 = new TblUserController().FetchAll().Where(x => x.UserId == total_id[i]).Single();
                    %>
                    <li class="w3-row">
                        <div class="top-type w3-col l2 w3-padding">
                            <label class="w3-large"><%=i + 1 %></label>
                        </div>
                        <div class="w3-col l2">
                            <img src="../Content/avatar/<%=get_top10.Avatar %>" />
                        </div>
                        <div class="w3-col l7">
                            <label><%=get_top10.FullName %></label><br />
                            <label class="w3-text-teal"><%=this.total_score[i] %></label><span> Điểm</span>
                        </div>
                    </li>
                    <%}
                          }
                      }
                      }
                        }%>
                </ul>
            </div>
        </div>
    </div>
    <script src="../Scripts/multiple-choice.js"></script>
</asp:Content>
